package com.wc.算法基础课.C第三讲搜索与图论.BFS.母亲的牛奶;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @Author congge
 * @Date 2024/3/16 23:29
 * @description https://www.acwing.com/problem/content/1357/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int[] up = new int[3];
    static int[] base = new int[]{10000, 100, 1};
    static int a, b, c;

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) up[i] = sc.nextInt();
        a = 0;
        b = 0;
        c = up[2];
        bfs();
    }

    static Queue<Integer> q = new LinkedList<>();
    static Set<Integer> set = new HashSet<>();

    static void bfs() {

        int t = c;
        set.add(t);
        q.add(t);
        while (!q.isEmpty()) {
            t = q.poll();
            int a = t / 10000;
            t %= 10000;
            int b = t / 100;
            int c = t % 100;
            // 1: c -> a
            move(2, 0, 1, c, a, b);
            
            // 2：c -> b
            move(2, 1, 0, c, b, a);

            // 3: a -> c
            move(0, 2, 1, a, c, b);

            // 4: a -> b
            move(0, 1, 2, a, b, c);

            // 5: b -> a
            move(1, 0, 2, b, a, c);

            // 6: b -> c
            move(1, 2, 0, b, c, a);
        }
        PriorityQueue<Integer> res = new PriorityQueue<>();
        for (int x : set) {
            if (x / 10000 == 0) {
                res.add(x % 100);
            }
        }
        while (!res.isEmpty()) {
            out.print(res.poll() + " ");
        }
        out.flush();
    }

    // a -> b倒
    static void move(int aI, int bI, int cI, int a, int b, int c) {
        int nc = c;
        int nb = Math.min(a + b, up[bI]);
        int na = Math.max(a + b - up[bI], 0);

        int t = na * base[aI] + nb * base[bI] + nc * base[cI];
        if (!set.contains(t)) {
            set.add(t);
            q.add(t);
        }
    }

    static int getX(int a, int b, int c) {
        return a * 10000 + b * 100 + c;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
